package cn.fl.sue.service.impl;

import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.sue.api.ISueApplyInfoApiService;
import cn.fl.sue.dto.SueApplyInfoDTO;
import cn.fl.sue.service.ISueApplyInfoService;
import cn.fl.sue.vo.SueApplyInfoVO;
import cn.fl.sue.voTransform.SueApplyInfoVOTransform;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作者:hongyanbo
 * 时间:2019-03-08
 */
@Service
public class SueApplyInfoServiceImpl implements ISueApplyInfoService {
    @Autowired
    private ISueApplyInfoApiService sueApplyInfoApiService;

    @Override
    public SueApplyInfoVO selectById(Long applyId) {
        return SueApplyInfoVOTransform.toVO(sueApplyInfoApiService.selectById(applyId));
    }

    @Override
    public List<SueApplyInfoVO> selectByDataId(Long dataId) {
        return SueApplyInfoVOTransform.toVOList(sueApplyInfoApiService.selectByDataId(dataId));
    }

    @Override
    public void modify(SueApplyInfoDTO sueApplyInfoDTO) {
        sueApplyInfoApiService.modify(sueApplyInfoDTO);
    }

    @Override
    public Long add(SueApplyInfoDTO sueApplyInfoDTO) {
        return sueApplyInfoApiService.add(sueApplyInfoDTO);
    }

    @Override
    public FlowStartParamsDTO getFlowStartParamsDTO(String orgCd, String buOrgCd, String modelTypCd, Long applyId,String tabNm) {
        FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
        flowStartParamsDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);
        flowStartParamsDTO.setWordsInTheTable("SUE");
        //flowStartParamsDTO.setProcDefKey(procDefKey);
        //flowStartParamsDTO.setProcDefId(procDefId);
        //flowStartParamsDTO.setProcNo(procNo);
        flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
        flowStartParamsDTO.setBusinessKey(String.valueOf(applyId));
        flowStartParamsDTO.setOrgCd(orgCd);
        flowStartParamsDTO.setSysCd(CurrentThreadContext.getFlServiceSysCd());
        flowStartParamsDTO.setBuOrgCd(buOrgCd);
        flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
        flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
        flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);
        flowStartParamsDTO.setBusinessType(tabNm);
        flowStartParamsDTO.setModelTyp(modelTypCd);
        return flowStartParamsDTO;
    }
}
